<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Time-Saving Tricks For Object Definitions</title>

<STYLE type="text/css">
<!--
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
        .PageTitle { font-family: verdana,arial,serif; font-size: 12pt; font-weight: bold; }
-->      
</STYLE>

</head>

<body bgcolor="#FFFFFF" text="black" class="Default">

<p>
<div align="center">
<h2 class="PageTitle">Time-Saving Tricks For Object Definitions</h2>
or...<br>
<b>"How To Preserve Your Sanity"</b>
</div>
</p>
<hr>

<p>
<strong><u>Introduction</u></strong>
</p>

<p>
This documentation attempts to explain how you can exploit the (somewhat) hidden features of <a href="xodtemplate.html">template-based object definitions</a> to save your sanity.  How so, you ask?  Several types of objects allow you to specify multiple host names and/or hostgroup names in definitions, allowing you to "copy" the object defintion to multiple hosts or services.  I'll cover each type of object that supports these features seperately.  For starters, the object types which support this time-saving feature are as follows:
</p>

<p>
<ul>
<li><a href="#service">Services</a>
<li><a href="#serviceescalation">Service escalations</a>
<li><a href="#servicedependency">Service dependencies</a>
<li><a href="#hostescalation">Host escalations</a>
<li><a href="#hostdependency">Host dependencies</a>
<li><a href="#hostgroup">Hostgroups</a>
</ul>
</p>

<p>
Object types that are not listed above (i.e. timeperiods, commands, etc.) do not support the features I'm about to describe.
</p>

<p>
<strong><u>Regular Expression Matching</u></strong>
</p>

<p>
The examples I give below use "standard" matching of object names.  If you wish, you can enable regular expression matching for object names by using the <a href="configmain.html#use_regexp_matching">use_regexp_matching</a> config option.  By default, regular expression matching will only be used in object names that contain the <b>*</b> and <b>?</b> wildcard characters.  If you want regular expression matching to be used on all object names (regardless of whether or not they contain the * and ? wildcard characters), enable the <a href="configmain.html#use_true_regexp_matching">use_true_regexp_matching</a> config option.
</p>

<p>
Regular expressions can be used in any of the fields used in the examples below (host names, hostgroup names, service names, and servicegroup names).
</p>

<p>
<strong>NOTE:</strong> Be careful when enabling regular expression matching - you may have to change your config file, since some directives that you might not want to be interpreted as a regular expression just might be!  Any problems should become evident once you verify your configuration.
</p>


<a name="service"></a>
<p>
<strong><u>Service Definitions</u></strong>
</p>

<p>
<b>Multiple Hosts:</b> If you want to create identical <a href="xodtemplate.html#service">services</a> that are assigned to multiple hosts, you can specify multiple hosts in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>service</i>{
		<font color="red">host_name		<i>HOST1,HOST2,HOST3,...,HOSTN</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other service directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service called <i>SOMESERVICE</i> on hosts <i>HOST1</i> through <i>HOSTN</i>.  All the instances of the <i>SOMESERVICE</i> service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).
</p>

<p>
<b>All Hosts In Multiple Hostgroups:</b> If you want to create identical services that are assigned to all hosts in one or more hostgroups, you can do so by creating a single service definition.  How?  The <i>hostgroup_name</i> directive allows you to specify the name of one or more hostgroups that the service should be created for:
</p>

<p>
<pre>
	define <i>service</i>{
		<font color="red">hostgroup_name		<i>HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other service directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service called <i>SOMESERVICE</i> on all hosts that are members of hostgroups <i>HOSTGROUP1</i> through <i>HOSTGROUPN</i>.  All the instances of the <i>SOMESERVICE</i> service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).
</p>

<p>
<b>All Hosts:</b> If you want to create identical services that are assigned to all hosts that are defined in your configuration files, you can use a wildcard in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>service</i>{
		<font color="red">host_name		<i>*</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other service directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service called <i>SOMESERVICE</i> on <b>all hosts</b> that are defined in your configuration files.  All the instances of the <i>SOMESERVICE</i> service would be identical (i.e. have the same check command, max check attempts, notification period, etc.).
</p>

<a name="serviceescalation"></a>
<p>
<strong><u>Service Escalation Definitions</u></strong>
</p>

<p>
<b>Multiple Hosts:</b> If you want to create <a href="xodtemplate.html#serviceescalation">service escalations</a> for services of the same name/description that are assigned to multiple hosts, you can specify multiple hosts in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">host_name		<i>HOST1,HOST2,HOST3,...,HOSTN</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service escalation for services called <i>SOMESERVICE</i> on hosts <i>HOST1</i> through <i>HOSTN</i>.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
<b>All Hosts In Multiple Hostgroups:</b> If you want to create service escalations for services of the same name/description that are assigned to all hosts in in one or more hostgroups, you can do use the <i>hostgroup_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">hostgroup_name		<i>HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service escalation for services called <i>SOMESERVICE</i> on all hosts that are members of hostgroups <i>HOSTGROUP1</i> through <i>HOSTGROUPN</i>.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
<b>All Hosts:</b> If you want to create identical service escalations for services of the same name/description that are assigned to all hosts that are defined in your configuration files, you can use a wildcard in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">host_name		<i>*</i></font>
		<font color="red">service_description	<i>SOMESERVICE</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service escalation for all services called <i>SOMESERVICE</i> on <b>all hosts</b> that are defined in your configuration files.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>


<p>
<b>All Services On Same Host:</b> If you want to create <a href="xodtemplate.html#serviceescalation">service escalations</a> for all services assigned to a particular host, you can use a wildcard in the <i>service_description</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">host_name		<i>HOST1</i></font>
		<font color="red">service_description	<i>*</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service escalation for <b>all</b> services on host <i>HOST1</i>.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
If you feel like being particularly adventurous, you can specify a wildcard in both the <i>host_name</i> and <i>service_description</i> directives.  Doing so would create a service escalation for <b>all services</b> that you've defined in your configuration files.
</p>

<p>
<b>Multiple Services On Same Host:</b> If you want to create <a href="xodtemplate.html#serviceescalation">service escalations</a> for all multiple services assigned to a particular host, you can use a specify more than one service description in the <i>service_description</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">host_name		<i>HOST1</i></font>
		<font color="red">service_description	<i>SERVICE1,SERVICE2,...,SERVICEN</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a service escalation for services <i>SERVICE1</i> through <i>SERVICEN</i> on host <i>HOST1</i>.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
<b>All Services In Multiple Servicegroups:</b> If you want to create service escalations for all services that belong in one or more servicegroups, you can do use the <i>servicegroup_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>serviceescalation</i>{
		<font color="red">servicegroup_name		<i>SERVICEGROUP1,SERVICEGROUP2,...,SERVICEGROUPN</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create service escalations for all services that are members of servicegroups <i>SERVICEGROUP1</i> through <i>SERVICEGROUPN</i>.  All the instances of the service escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>


<a name="servicedependency"></a>
<p>
<strong><u>Service Dependency Definitions</u></strong>
</p>

<p>
<b>Multiple Hosts:</b> If you want to create <a href="xodtemplate.html#servicedependency">service dependencies</a> for services of the same name/description that are assigned to multiple hosts, you can specify multiple hosts in the <i>host_name</i> and or <i>dependent_host_name</i> directives as follows:
</p>

<p>
<pre>
	define <i>servicedependency</i>{
		<font color="red">host_name			<i>HOST1,HOST2</i></font>
		<font color="red">service_description		<i>SERVICE1</i></font>
		<font color="red">dependent_host_name		<i>HOST3,HOST4</i></font>
		<font color="red">dependent_service_description	<i>SERVICE2</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
In the example above, service <i>SERVICE2</i> on hosts <i>HOST3</i> and <i>HOST4</i> would be dependent on service <i>SERVICE1</i> on hosts <i>HOST1</i> and <i>HOST2</i>.  All the instances of the service dependencies would be identical except for the host names (i.e. have the same notification failure criteria, etc.).
</p>

<p>
<b>All Hosts In Multiple Hostgroups:</b> If you want to create service dependencies for services of the same name/description that are assigned to all hosts in in one or more hostgroups, you can do use the <i>hostgroup_name</i> and/or <i>dependent_hostgroup_name</i> directives as follows:
</p>

<p>
<pre>
	define <i>servicedependency</i>{
		<font color="red">hostgroup_name			<i>HOSTGROUP1,HOSTGROUP2</i></font>
		<font color="red">service_description		<i>SERVICE1</i></font>
		<font color="red">dependent_hostgroup_name	<i>HOSTGROUP3,HOSTGROUP4</i></font>
		<font color="red">dependent_service_description	<i>SERVICE2</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
In the example above, service <i>SERVICE2</i> on all hosts in hostgroups <i>HOSTGROUP3</i> and <i>HOSTGROUP4</i> would be dependent on service <i>SERVICE1</i> on all hosts in hostgroups <i>HOSTGROUP1</i> and <i>HOSTGROUP2</i>.  Assuming there were five hosts in each of the hostgroups, this definition would be equivalent to creating 100 single service dependency definitions!  All the instances of the service dependency would be identical except for the host names (i.e. have the same notification failure criteria, etc.).
</p>

<p>
<b>All Services On Same Host:</b> If you want to create service dependencies for all services assigned to a particular host, you can use a wildcard in the <i>service_description</i> and/or <i>dependent_service_description</i> directives as follows:
</p>

<p>
<pre>
	define <i>servicedependency</i>{
		<font color="red">host_name			<i>HOST1</i></font>
		<font color="red">service_description		<i>*</i></font>
		<font color="red">dependent_host_name		<i>HOST2</i></font>
		<font color="red">dependent_service_description	<i>*</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
In the example above, <b>all services</b> on host <i>HOST2</i> would be dependent on <b>all services</b> on host <i>HOST1</i>.  All the instances of the service dependencies would be identical (i.e. have the same notification failure criteria, etc.).
</p>

<p>
<b>Multiple Services On Same Host:</b> If you want to create service dependencies for multiple services assigned to a particular host, you can specify more than one service description in the <i>service_description</i> and/or <i>dependent_service_description</i> directives as follows:
</p>

<p>
<pre>
	define <i>servicedependency</i>{
		<font color="red">host_name			<i>HOST1</i></font>
		<font color="red">service_description		<i>SERVICE1,SERVICE2,...,SERVICEN</i></font>
		<font color="red">dependent_host_name		<i>HOST2</i></font>
		<font color="red">dependent_service_description	<i>SERVICE1,SERVICE2,...,SERVICEN</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
<b>All Services In Multiple Servicegroups:</b> If you want to create service dependencies for all services that belong in one or more servicegroups, you can do use the <i>servicegroup_name</i> and/or <i>dependent_servicegroup_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>servicedependency</i>{
		<font color="red">servicegroup_name		<i>SERVICEGROUP1,SERVICEGROUP2,...,SERVICEGROUPN</i></font>
		<font color="red">dependent_servicegroup_name	<i>SERVICEGROUP3,SERVICEGROUP4,...SERVICEGROUPN</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>


<a name="hostescalation"></a>
<p>
<strong><u>Host Escalation Definitions</u></strong>
</p>

<p>
<b>Multiple Hosts:</b> If you want to create <a href="xodtemplate.html#hostescalation">host escalations</a> for  multiple hosts, you can specify multiple hosts in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>hostescalation</i>{
		<font color="red">host_name		<i>HOST1,HOST2,HOST3,...,HOSTN</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a host escalation for hosts <i>HOST1</i> through <i>HOSTN</i>.  All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
<b>All Hosts In Multiple Hostgroups:</b> If you want to create host escalations for all hosts in in one or more hostgroups, you can do use the <i>hostgroup_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>hostescalation</i>{
		<font color="red">hostgroup_name		<i>HOSTGROUP1,HOSTGROUP2,...,HOSTGROUPN</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a host escalation on all hosts that are members of hostgroups <i>HOSTGROUP1</i> through <i>HOSTGROUPN</i>.  All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>

<p>
<b>All Hosts:</b> If you want to create identical host escalations for all hosts that are defined in your configuration files, you can use a wildcard in the <i>host_name</i> directive as follows:
</p>

<p>
<pre>
	define <i>hostescalation</i>{
		<font color="red">host_name		<i>*</i></font>
		<i>other escalation directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a hosts escalation for <b>all hosts</b> that are defined in your configuration files.  All the instances of the host escalation would be identical (i.e. have the same contact groups, notification interval, etc.).
</p>


<a name="hostdependency"></a>
<p>
<strong><u>Host Dependency Definitions</u></strong>
</p>

<p>
<b>Multiple Hosts:</b> If you want to create <a href="xodtemplate.html#hostdependency">host dependencies</a> for  multiple hosts, you can specify multiple hosts in the <i>host_name</i> and/or <i>dependent_host_name</i> directives as follows:
</p>

<p>
<pre>
	define <i>hostdependency</i>{
		<font color="red">host_name		<i>HOST1,HOST2</i></font>
		<font color="red">dependent_host_name	<i>HOST3,HOST4,HOST5</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
The definition above would be equivalent to creating six seperate host dependencies.   In the example above, hosts <i>HOST3</i>, <i>HOST4</i> and <i>HOST5</i> would be dependent upon both <i>HOST1</i> and <i>HOST2</i>.  All the instances of the host dependencies would be identical except for the host names (i.e. have the same notification failure criteria, etc.).
</p>

<p>
<b>All Hosts In Multiple Hostgroups:</b> If you want to create host escalations for all hosts in in one or more hostgroups, you can do use the <i>hostgroup_name</i> and /or <i>dependent_hostgroup_name</i> directives as follows:
</p>

<p>
<pre>
	define <i>hostdependency</i>{
		<font color="red">hostgroup_name			<i>HOSTGROUP1,HOSTGROUP2</i></font>
		<font color="red">dependent_hostgroup_name	<i>HOSTGROUP3,HOSTGROUP4</i></font>
		<i>other dependency directives</i> ...
		}
</pre>
</p>

<p>
In the example above, all hosts in hostgroups <i>HOSTGROUP3</i> and <i>HOSTGROUP4</i> would be dependent on all hosts in hostgroups <i>HOSTGROUP1</i> and <i>HOSTGROUP2</i>.  All the instances of the host dependencies would be identical except for  host names (i.e. have the same notification failure criteria, etc.).
</p>

<a name="hostgroup"></a>
<p>
<strong><u>Hostgroups</u></strong>
</p>

<p>
<b>All Hosts:</b> If you want to create a hostgroup that has all hosts that are defined in your configuration files as members, you can use a wildcard in the <i>members</i> directive as follows:
</p>

<p>
<pre>
	define <i>hostgroup</i>{
		<i>hostgroup_name</i>		<i>HOSTGROUP1</i>
		<font color="red">members			<i>*</i></font>
		<i>other hostgroup directives</i> ...
		}
</pre>
</p>

<p>
The definition above would create a hostgroup called <i>HOSTGROUP1</i> that has all <b>all hosts</b> that are defined in your configuration files as members.
</p>


<hr>

</body>
</html>
